﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using GPS.Models;

namespace GPS.Controllers
{
    public class TraceController : Controller
    {
        //
        // GET: /Trace/
        BaseDao basedao = new BaseDao();

        public ActionResult Orbit()
        {
            return View("Orbit");
        }

        public ActionResult GetOrbit()
        {
            string IMEI = Request.Form["IMEI"];
            string start = Request.Form["start"];
            string end = Request.Form["end"];
            try
            {
                string sql = "SELECT lat as Latitude,lon as Longitude FROM GPSTest where IMEI='" + IMEI + "' and lat<>'heart'  and time between '" + start + "' and '" + end + "' order by time asc";
                List<Dictionary<string, object>> list = basedao.GetList(sql, new string[] { "Longitude", "Latitude" });
                if (list.Count > 0)
                {
                    return Json(list);
                }
                else
                {
                    return Json("0");
                }
            }
            catch (Exception ex)
            {
                //Dictionary<string, object> datalog = new Dictionary<string, object>();
                //datalog.Add("type", int.Parse("2"));
                //datalog.Add("OpTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                //datalog.Add("OpID", Session["operatorID"]);
                //datalog.Add("OpLog", "异常：查询轨迹错误/TrackController/guijiTest:" + ex.Message.ToString().Replace("'", ""));
                //basedao.save("T_LOG", datalog);
                return Json('0');        //错误返回值
            }
        }

        public ActionResult TestMethod()
        {
            return Json("执行生效");
        }



    }
}
